from selenium import webdriver
import time
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


driver = webdriver.Chrome()
driver.get("https://www.baidu.com")
driver.maximize_window()
wait = WebDriverWait(driver, 10,0.1)

actions = ActionChains(driver)
settings =wait.until(EC.presence_of_element_located((By.ID, 's-usersetting-top')))
actions.move_to_element(settings).click().perform()

settings_search =wait.until(EC.presence_of_element_located((By.CLASS_NAME, 'set')))
actions.move_to_element(settings_search).click().perform()

btn_save =wait.until(EC.presence_of_element_located((By.XPATH, '//a[text()="保存设置"]')))
btn_save.click()

alert =wait.until(EC.alert_is_present())
alert.accept()
# alert.accept()

input("按回车退出")
driver.quit()














